package com.fr.report.highlight;

import com.fr.base.FRFont;
import com.fr.base.Style;
import com.fr.base.xml.BaseXMLUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.CellElement;
import com.fr.report.Report;
import com.fr.report.script.Calculator;
import java.util.Iterator;

public class FRFontHighlightAction extends AbstractHighlightAction
{
  private FRFont font = FRFont.getInstance();
  private int scope = 0;

  public FRFontHighlightAction()
  {
  }

  public FRFontHighlightAction(FRFont paramFRFont, int paramInt)
  {
    this.font = paramFRFont;
    this.scope = paramInt;
  }

  public FRFont getFRFont()
  {
    return this.font;
  }

  public void setFRFont(FRFont paramFRFont)
  {
    this.font = paramFRFont;
  }

  public int getScope()
  {
    return this.scope;
  }

  public void setScope(int paramInt)
  {
    this.scope = paramInt;
  }

  public void action(CellElement paramCellElement, Calculator paramCalculator)
  {
    if (paramCellElement == null)
      return;
    Report localReport = paramCalculator.getCurrentReport();
    switch (getScope())
    {
    case 1:
      if (localReport == null)
        return;
      int i = paramCellElement.getRow();
      Iterator localIterator1 = localReport.getRow(i);
      while (true)
      {
        if (!(localIterator1.hasNext()))
          return;
        modifyFRFont((CellElement)localIterator1.next(), this.font);
      }
    case 2:
      if (localReport == null)
        return;
      int j = paramCellElement.getColumn();
      Iterator localIterator2 = localReport.getColumn(j);
      while (true)
      {
        if (!(localIterator2.hasNext()))
          return;
        modifyFRFont((CellElement)localIterator2.next(), this.font);
      }
    }
    modifyFRFont(paramCellElement, this.font);
  }

  private void modifyFRFont(CellElement paramCellElement, FRFont paramFRFont)
  {
    if (paramCellElement == null)
      return;
    Style localStyle = paramCellElement.getStyle();
    paramCellElement.setStyle(localStyle.deriveFRFont(paramFRFont));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str2 = paramXMLableReader.getTagName();
      if (BaseXMLUtils.isFRFontTagName(str2))
      {
        this.font = BaseXMLUtils.readFRFont(paramXMLableReader);
      }
      else if ("Scope".equals(str2))
      {
        String str1;
        if ((str1 = paramXMLableReader.getAttr("val")) != null)
          setScope(Integer.parseInt(str1));
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if ((this.font != null) && (this.font != FRFont.getInstance()))
      BaseXMLUtils.writeFRFont(paramXMLPrintWriter, this.font);
    if (getScope() != 0)
      paramXMLPrintWriter.startTAG("Scope").attr("val", getScope()).end();
  }
}